package com.springmvc.web.entity;

public class Pager {

	private int rows = 5 ; //每页大小	
	private int totalPage ; //总页数
	private int total ; //数据总数
	private int page = 1; //当前页
	private int startrow ;	//当前页开始行数
	private int endrow ; //当前页结束行数
	private int prePage ;// 上一页
	private int nextPage ;// 下一页    

	
	public Pager(){
		   
	   }
	
	/*   
	   public Pager(int total,int rows,int page){
	    	
		    this.rows = rows ;
	    	this.total = total ;
	    	this.page = page ;
	    	  
	    	setTotal(total);
	    	setPage(page);

		    }
    */
		
		public int getRows() {
			return rows;
		}
		public void setRows(int rows) {
			this.rows = rows;
		}
		
	    	   
	    public int getPage() {
			
	    	 if(page <= 0){					
					this.page =	1;			
				}else if( page > getTotalPage()){					
					this.page =  getTotalPage();
				}	    	
	    	     return this.page;
		       }	    	    
		public void setPage(int page) {
			this.page = page ;	
		}
		
	     
		public int getStartrow() {
			this.startrow = (this.page - 1) * this.rows;			
			return this.startrow;
		}
		public void setStartrow(int startrow) {
			this.startrow = startrow;
		}

		

		public int getEndrow() {
			return endrow;
		}
		public void setEndrow(int endrow) {
			this.endrow = this.page * this.rows ;
		}

		
		
		public int getTotal() {
			return total;
		}
		public void setTotal(int total) {
			
			this.total = total;
		}
		
		
		public int getTotalPage() {
			
			if(this.total % this.rows == 0){
				  
				this.totalPage = this.total / this.rows;
			
			}else{
				this.totalPage = this.total / this.rows + 1;
		         }
			
			return this.totalPage;
		}		
		public void setTotalPage(int totalPage) {
			
			this.totalPage = totalPage;			
		}
		
   
		public int getPrePage() {
			return prePage;
		}
		public void setPrePage(int prePage) {
			this.prePage = this.page - 1;
		}


		public int getNextPage() {
			return nextPage;
		}
		public void setNextPage(int nextPage) {
			this.nextPage = this.page + 1;
		}

		
}
